#include <bits/stdc++.h>
using namespace std;
int T;
int n, m, L, V;
int d[100005], v[100005], a[100005], p[100005];

int main()
{
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	
	cin >> T;
	while (T--){
		int ans = 0;
		cin >> n >> m >> L >> V;
		for (int i = 1; i <= n; i++)
			cin >> d[i] >> v[i] >> a[i];
		for (int i = 1; i <= m; i++)
			cin >> p[i];
		bool vis[100005];
		memset(vis, false, sizeof(vis));
		for (int i = 1; i <= n; i++){
			if (a[i] == 0){
				if (v[i] > V){
					for (int j = 1; j <= m; j++)
						if (p[j] >= d[i]){
							ans++;
							vis[j] = true;
							break;
						}
				}
			} else {
				int reach = ceil(1.0 * (V * V - v[i] * v[i]) / (2 * a[i]));
				if (a[i] > 0){
					for (int j = 1; j <= m; j++)
						if (p[j] >= reach){
							ans++;
							vis[j] = true;
							break;
						}
				} else {
					for (int j = 1; j <= m; j++)
						if (p[j] < reach && p[j] >= d[i]){
							ans++;
							vis[j] = true;
							break;
						}
				}
			}
		}
		cout << ans + 1 << " ";
		ans = 0;
		for (int i = 1; i <= m; i++)
			if (!vis[i])
				ans++;
		cout << ans << endl;
	}
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
}
